Scenario #9210: Create Global Admin Subject Without an Own Account

UseCase Create Global Admin Subject Without Account => Global-Admin Subject: hsh-keycloak_sync

Creating accounts needs an acting global-admin USER subject, but that subject does not need to have an own account (and thus a person) itself. Here, such a subject gets created: it is synchronized from Keycloak, and the global ADMIN role is granted to it, but no account is created for it.

Properties

Given

name value
subjectUuid 242a0007-0000-0000-0000-000000000007
subjectName hsh-keycloak_sync

Synchronize the new USER Subject from Keycloak

HTTP PUT "/api/rbac/subjects/242a0007-0000-0000-0000-000000000007" \
  -H "Authorization: Bearer $HSADMINNG_JWT_BEARER" \
  `# {` \
  `#   "sub" : "uuid<hsh-alex_superuser>"` \
  `# }` \
  -H 'Content-Type: application/json' \
  --data-binary @- <<EOF
{
  "name" : "hsh-keycloak_sync",
  "type" : "USER"
}
EOF
=> status: 201 CREATED 242a0007-0000-0000-0000-000000000007

This is what the Keycloak sync program does for each new Keycloak user.

Prerequisite: Resolve the UUID of the global ADMIN role

The grant API needs the UUID of the role which we want to grant.

HTTP GET "/api/rbac/roles?name=rbac.global%23global%3AADMIN" \
  -H "Authorization: Bearer $HSADMINNG_JWT_BEARER" \
  `# {` \
  `#   "sub" : "uuid<hsh-alex_superuser>"` \
  `# }`
=> status: 200 OK 
[ {
  "uuid" : "529596de-9d7c-40a8-8f6d-87d8d6af2eb6",
  "object.uuid" : "9c5d7389-e015-4821-8b5e-1752452cbb88",
  "objectTable" : "rbac.global",
  "objectIdName" : "global",
  "roleType" : "ADMIN",
  "roleName" : "rbac.global#9c5d7389-e015-4821-8b5e-1752452cbb88:ADMIN",
  "roleIdName" : "rbac.global#global:ADMIN"
} ]

Grant the global ADMIN role to the new USER Subject

HTTP POST "/api/rbac/grants" \
  -H "Authorization: Bearer $HSADMINNG_JWT_BEARER" \
  `# {` \
  `#   "sub" : "uuid<hsh-alex_superuser>"` \
  `# }` \
  -H 'Hostsharing-Assumed-Roles: rbac.global#global:ADMIN' \
  -H 'Content-Type: application/json' \
  --data-binary @- <<EOF
{
  "assumed" : true,
  "grantedRole.uuid" : "529596de-9d7c-40a8-8f6d-87d8d6af2eb6", // globalAdminRoleUuidToGrant
  "granteeSubject.uuid" : "242a0007-0000-0000-0000-000000000007"
}
EOF
=> status: 201 CREATED 529596de-9d7c-40a8-8f6d-87d8d6af2eb6 // globalAdminRoleUuidToGrant

Verify the new global-admin Subject does not have an own Account

HTTP GET "/api/hs/accounts/current" \
  -H "Authorization: Bearer $HSADMINNG_JWT_BEARER" \
  `# {` \
  `#   "sub" : "uuid<hsh-keycloak_sync>"` \
  `# }`
=> status: 200 OK 
{
  "subject" : {
    "uuid" : "242a0007-0000-0000-0000-000000000007",
    "name" : "hsh-keycloak_sync",
    "type" : "USER"
  },
  "person" : null,
  "globalAdmin" : true
}

generated on 2026-07-17 01:42:19 for branch